package com.cqjudicial.umtest.umeng.onkeyloginconfig;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Build;
import android.view.Gravity;
import android.view.View;

import com.cqjudicial.umtest.R;
import com.umeng.umverify.UMVerifyHelper;
import com.umeng.umverify.view.UMAbstractPnsViewDelegate;
import com.umeng.umverify.view.UMAuthRegisterXmlConfig;
import com.umeng.umverify.view.UMAuthUIConfig;

/**
 * xml文件方便预览
 * 可以通过addAuthRegisterXmlConfig一次性统一添加授权页的所有自定义view
 */
public class CustomXmlConfig extends BaseUIConfig {
    Activity activity;

    public CustomXmlConfig(Activity activity, UMVerifyHelper authHelper) {
        super(activity, authHelper);
    }

    @Override
    public void configAuthPage() {
        mAuthHelper.removeAuthRegisterXmlConfig();
        mAuthHelper.removeAuthRegisterViewConfig();
        int authPageOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        if (Build.VERSION.SDK_INT == 26) {
            authPageOrientation = ActivityInfo.SCREEN_ORIENTATION_BEHIND;
        }
        mAuthHelper.addAuthRegisterXmlConfig(new UMAuthRegisterXmlConfig.Builder()
                .setLayout(R.layout.activity_main, new UMAbstractPnsViewDelegate() {
                    @Override
                    public void onViewCreated(View view) {

//                        ImageView pImageView = (ImageView) findViewById(R.id.iv_background);
//                        Glide.with(mContext).load(R.drawable.test).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(pImageView);

                    }
                })
                .build());


        mAuthHelper.setAuthUIConfig(new UMAuthUIConfig.Builder()
                .setAppPrivacyOne("《一锤用户协议》", "fde"
                        + "/api/share/agreement")
//                .setAppPrivacyTwo("《百度》", "https://www.baidu.com")
                .setAppPrivacyColor(Color.parseColor("#858ca3"), Color.parseColor("#198FF6"))
                .setLogoImgPath("logo_sque")
                .setStatusBarHidden(false)
                .setNavHidden(true)
                .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
                .setSloganTextColor(Color.parseColor("#ff011340"))
                .setLogBtnText("本机号码一键登录")
                .setLogBtnBackgroundPath("button_bg_theme")
                .setLogBtnHeight(40)
                .setPrivacyState(true)
                .setProtocolGravity(Gravity.LEFT)
                .setPrivacyTextSize(14)
                .setPrivacyBefore("登录即同意")
                .setVendorPrivacyPrefix("《")
                .setVendorPrivacySuffix("》")
                .setLogBtnToastHidden(false)
                .setSwitchAccHidden(true)
                //调整位置
                .setLogoHeight(56)
                .setLogoOffsetY(96)//logo
                .setSloganOffsetY(168)//服务商名
                .setLogBtnOffsetY(400)
//                .setNavHidden(true)
//                .setLogoHidden(true)
//                .setSloganHidden(true)
//                .setSwitchAccHidden(true)
//                .setPrivacyState(false)
//                .setCheckboxHidden(true)
//                .setLightColor(true)
//
//                .setStatusBarColor(Color.TRANSPARENT)
//                .setStatusBarUIFlag(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
//                .setWebNavTextSize(20)
//                .setNumberSize(20)
//                .setNumberColor(Color.BLACK)
//                .setAuthPageActIn("in_activity", "out_activity")
//                .setAuthPageActOut("in_activity", "out_activity")
//                .setVendorPrivacyPrefix("《")
//                .setVendorPrivacySuffix("》")
//                .setPageBackgroundPath("page_background_color")
//                .setLogoImgPath("mytel_app_launcher")
//                .setLogBtnBackgroundPath("login_btn_bg")
//                .setScreenOrientation(authPageOrientation)
                .create());
    }
}
